////
////  Account.swift
////  TestBankActor
////
////  Created by 罗万能 on 2025/6/17.
////
//typealias Account = AccountV1
//
//import Foundation
//import SwiftData
//
//@Model
//class AccountV1{
//    var id: UUID
//    var balance: Double
//    var name: String
//    init(id: UUID = UUID(), balance: Double,name: String = "Account\(Int.random(in: 1...9))") {
//        self.id = id
//        self.balance = balance
//        self.name = name
//    }
//    
//   
//}
//
//
//@ModelActor
//actor AccountActor{
//    func trans(from : Account,to :Account,amount: Double) async{
//        if  from.balance >= amount{
//            from.balance -= amount
//            try! await Task.sleep(nanoseconds: 2_000_000)
//            to.balance += amount
//        }else{
////            await from.deposit(amount: amount)
//        }
//    }
//    
//    func deposit(account: Account,amount: Double) -> Bool{
//        guard amount > 0 else {
//            print("Account: \(account.name) ,desposit \(amount) wrong!!!!")
//            return false}
//        balance += amount
//        print("Account: \name ,desposit \(amount) ,balance: \(account.balance)")
//        return true
//    }
//    //取款
//    func withdraw(account: Account,amount: Double) -> Bool{
//        guard amount > 0 && balance - amount >= 0 else {
//            print("Account: \(name) ,withdraw \(amount) wrong!!!!")
//            return false}
//        balance -= amount
//        print("Account: \(name) ,withdraw \(amount),balance: \(balance)")
//    return true
//    }
//    
//    func accountInfo(account: Account,) {
//        print( "Account: \(name) ,balance: \(balance)")
//    }
//}
